<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统</title>
<meta name="keywords" content="">
<meta name="description" content="">
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie6.css"/>
<![endif]-->
<link href="__PUBLIC__/admin/css/style_v2.0.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css"  href="../../../../public/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/style_v2.0.css" />
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>

<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/calendar/win2k.css"/>
<script type="text/javascript" src="__PUBLIC__/js/calendar/calendar.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/calendar/lang/en.js"></script>
</head>
<body>
<div class="position mt10">当前位置：<a href="__APP__">后台首页</a> > <a href="{:U('User/admin_list')}">管理员列表</a></div>
<div id="container">
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
      <legend>添加管理员</legend>
  </fieldset>
<div class="layui-form" style="background-color:#FFFFFF;">
    <table class="layui-table">
	<form name="reg" action="{:U('Admin/User/admin_update')}" enctype="multipart/form-data"  method="post"  class="layui-form layui-form-item">
    <tr>
	  <td width="20%"><font color=red size="1">·</font>名   字：</td>
	  <td width="80%">
      <span class="table_span" style="width:400px; float:left;"><input name="username" type="text" id="username" value="" required  lay-verify="required" placeholder="请输入名字" autocomplete="off" class="layui-input">
      </span>
      <span class="table_txt" id="check" style="color:#999999; float:left">添加多个域名请用英文逗号(,)隔开</span> 
      </td>
    </tr>
	<tr>
	  <td><font color=red size="1">·</font>密 码：</td>
	  <td>
      <span class="table_span" style="width:400px; float:left;">
      <input name="password" type="password" id="password" value="" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
      </span>
      <span class="table_txt" id="checkpwd" style="color:#999999; float:left">(密码长度6-16位，使用字母数字或者下划线)</span>
      </td>
	</tr>
      <tr>
	  <td><font color=red size="1">·</font>重复密码：</td>
	  <td>
      <span class="table_span" style="width:400px; float:left;">
      <input name="password2" type="password" id="password2" value=""  placeholder="请输入新密码" autocomplete="off" class="layui-input">
      </span>
      <span  class="table_txt"   id="checkpwd2"></span>
      </td>
      </tr>
      <tr>
	  <td><font color=red size="1">·</font>邮箱：</td>
	  <td>
      <span class="table_span" style="width:400px; float:left;">
      <input name="email" type="text" id="email" value="" size="50"  placeholder="请输入邮箱" autocomplete="off" class="layui-input">
      </span>
      <span  class="table_txt" id="checkemail"></span>
      </td>
      </tr>
	  <tr>
	  <td><font color=red size="1">·</font>权 限：</td>
	  <td>
           <span class="table_span" style="width:200px; float:left;">
          <select id="admintype" name="admintype"  lay-verify="">
              <option value="0" >超级管理员</option>
              <option value="1" >普通管理员</option>
              <option value="2" >业务员</option>
          </select>
          </span>
      </td>
	  </tr>
	  <tr>
	  <td><font color=red size="1">·</font>添加时间：</td>
	  <td>
         <span class="table_span" style="width:200px; float:left;">
         <input name="addtime" type="text" id="addtime" value="{$now|date="Y-m-d H:i:s",###}" size="50" valuetype="string"  mustinput="true" class="layui-input ico-date" readonly></span>
      </td>
	  </tr>
      <tr> 
	  <td colspan=2 align="center" valign="middle">
		<input type="submit" name="Submit" value="确&nbsp; &nbsp;定" class="layui-btn" >
		<input type="reset" name="Submit2" value="重　置" class="layui-btn layui-btn-primary" >		 </td>
	</tr>
      </form>
    </table>
</div>
</div>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
</body>
</html>
<script>
layui.use(['form','laydate'], function(){
  var form = layui.form
  ,laydate = layui.laydate;
  
  laydate.render({
    elem: '#addtime'
	,type: 'datetime'
  });
  //监听提交
  form.on('submit(btnsub)', function(data){
    //layer.msg(JSON.stringify(data.field));
	title: '最终的提交信息'
	return true;
  });

})
</script>
<script>
   $(function(){
        $("#username").blur(function(){
			var username = $("#username").val();
			if(username = "" || username.length ==0 ){
				$("#check").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>用户名不能为空！</font>");
			}else{
				$("#check").html("正在读取数据...");
				$.ajax({
					url:"{:U('Admin/User/admin_ajax')}",
					dataType:"json",
					data: {'username':$("#username").val()},
					type:'post',
					success:function(data){
						if (data == 0){
						   $("#check").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>含有非法字符！</font>");
						   $("input[name='submit']").attr({'disabled':'true','title':'禁止提交'}).css({'background-Color':'#ccc'});
						}else if (data == 1){
						   $("#check").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>用户名不能为空！</font>");
						   $("input[type='submit']").attr({'disabled':'true','title':'禁止提交'}).css({'background-Color':'#ccc'});
						}else if(data == 2){
						   $("#check").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>用户名已存在！</font>");
						   $("input[type='submit']").attr({'disabled':'true','title':'禁止提交'}).css({'background-Color':'#ccc'});
						}else if (data == 3){
						   $("#check").html("<img src='__PUBLIC__/admin/images/dh.png'>");
						   $("input[type='submit']").removeAttr('disabled').css({'background-Color':'#009688'});
						}
				   }
				});
			}
		});//账号判断
		/*密码判定*/
		$("#password").blur(function(){
			 var password=$("#password").val();
			 if (password =="" || password.length == "0"){
				 $("#checkpwd").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>密码不能为空</font>");
				 $(this).focus();
				  $("input[type='submit']").attr({'disabled':'true','title':'禁止提交'}).css({'background-Color':'#ccc'});
			 }else{
				 if(password.length < 6 || password.length >16){
					 $("#checkpwd").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>密码长度是6-16位</font>");
					 $(this).focus();
					  $("input[type='submit']").attr({'disabled':'true','title':'禁止提交'}).css({'background-Color':'#ccc'});
				 }else{
					$("#checkpwd").html("<img src='__PUBLIC__/admin/images/dh.png'>");
					$("input[type='submit']").removeAttr('disabled').css({'background-Color':'#009688'});
				 }
			 }
		});
		/*重复密码判定*/
		$("#password2").blur( function(){
			 var password=$("#password").val();
			 var password2=$("#password2").val();
			 if (password2 == password){
				 $("#checkpwd2").html("<img src='__PUBLIC__/admin/images/dh.png'>");
				 $("input[type='submit']").removeAttr('disabled').css({'background-Color':'#009688'});
			 }else{
				 $("#checkpwd2").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>两次密码不一致</font>");
				 $("input[type='submit']").attr({'disabled':'true'}).css({'background-Color':'#ccc'});
			 }
		})
	   /*邮箱*/
	   $("#email").blur( function(){
		  var pattern = /^[a-zA-Z0-9]+([_\.-]*[a-zA-Z0-9]+)*@[a-zA-Z0-9]([-]?[a-zA-Z0-9]+)\.[a-zA-Z]{2,3}(\.[a-zA-Z](2))?$/;
		  var email=$("#email").val();
		  if(pattern.test(email)){
			 $("#checkemail").html("<img src='__PUBLIC__/admin/images/dh.png'>");
			 $("input[type='submit']").removeAttr('disabled').css({'background-Color':'#009688'});
		  }else{
			 $("#checkemail").html("<img src='__PUBLIC__/admin/images/cuo.png'>&nbsp;<font color=red>邮箱格式错误</font>");
			 $("input[type='submit']").attr({'disabled':'true'}).css({'background-Color':'#ccc'});
		  }  
	   });
   });
</script>
